Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not add pay later button in editor (3535) #2570

Merged
merged 6 commits into from
Oct 30, 2024

Conversation

AlexP11223
Copy link
Contributor

In 4e34332 we removed all APMs in editor because it is difficult to determine which APMs are available when registering buttons separately in editor, canMakePayment does not work there.

But fundingSource was not set to paypal, so it could still render at least Pay Later button (in the same express payment method cell, breaking layout when there are other methods).

Fixed that, now only one PayPal button can be shown in editor.

@alexflorisca
Copy link
Member

Hey there, just checking up on this PR as it was ready to merge a month ago? Is there a reason it hasn't yet? \cc @InpsydeNiklas

@InpsydeNiklas InpsydeNiklas changed the title Do not add pay later button in editor Do not add pay later button in editor (3535) Oct 30, 2024
@InpsydeNiklas InpsydeNiklas added this to the 2.9.4 milestone Oct 30, 2024
@Dinamiko Dinamiko merged commit 4457dfe into trunk Oct 30, 2024
9 checks passed
@Dinamiko Dinamiko deleted the PCP-3535-fix-editor-paypal-buttons-grid branch October 30, 2024 10:46
@InpsydeNiklas
Copy link
Member

@alexflorisca We found some remaining edge-case issues where incorrect buttons were displayed in the editor, which seemed more difficult to resolve. However, we merged this now and will include it with #2448 in the upcoming 2.9.4 update.

@alexflorisca
Copy link
Member

Thanks @InpsydeNiklas. Just to be annoying, I think the best UX would be to render the PayLater button as a separate button, if it's enabled in the backend. Otherwise the merchant and shopper UX will be different!

Editor:
Screenshot 2024-11-01 at 16 40 37

Frontend:
Screenshot 2024-11-01 at 16 40 10

(You can see similar discrepancies with WooPayments too).

It would be great to address this too.

@InpsydeNiklas
Copy link
Member

@alexflorisca I completely agree! Disabling the non-PayPal buttons (which also includes Venmo) is more of a temporary workaround to prevent the layout in the editor from breaking.
The problem is that the buttons rendered in the editor are using the PayPalButtons component from the PayPal React library. However, as far as I am aware, this component currently does not allow us to split the buttons into individual ones, like how it works in the frontend. We continue to look for ways to make it work, but it won't be ready for this release cycle, so we settled on this workaround for now.

@AlexP11223
Copy link
Contributor Author

AlexP11223 commented Nov 1, 2024

Splitting may be possible (or we can try again to use the same library as in frontend), but the main problem is determining which buttons are available (e.g. for the merchant/shop country).

In frontend we use canMakePayment with async promises, but in editor it is not called for some reason.

canMakePayment: async () => {
if ( ! paypalScriptPromise ) {
paypalScriptPromise = loadPayPalScript(
namespace,
config.scriptData
);
paypalScriptPromise.then( () => {
const messagesBootstrap =
new BlockCheckoutMessagesBootstrap(
config.scriptData
);
messagesBootstrap.init();
} );
}
await paypalScriptPromise;
return ppcpBlocksPaypalExpressButtons
.Buttons( { fundingSource } )
.isEligible();
},

So unless there is a way to get something like canMakePayment in editor, we would need to figure out some other way to determine the buttons availability earlier (before the express methods registration, e.g. on the server side) without the PayPal JS SDK.

@Dinamiko Dinamiko added the enhancement New feature or request label Nov 5, 2024
@Dinamiko Dinamiko mentioned this pull request Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multiple PayPal buttons are rendered in one express payment container (3535)
5 participants